class Solution
{
public:
    bool mergeTriplets(vector<vector<int>> &triplets, vector<int> &target)
    {
        vector<int> cur{0, 0, 0};
        for (auto &triplet : triplets)
        {
            bool valid = true;
            for (int i = 0; i < 3; ++i)
            {
                if (triplet[i] > target[i])
                {
                    valid = false;
                    break;
                }
            }
            if (!valid)
            {
                continue;
            }
            for (int i = 0; i < 3; ++i)
            {
                cur[i] = max(cur[i], triplet[i]);
            }
        }
        return cur == target;
    }
};